<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ page import="com.scalar.chiptrack.utils.ConfigManager" %>
<%@ page import="com.scalar.chiptrack.commons.Constants" %>
<%@ page import="com.scalar.chiptrack.jasper.JasperReports" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<HTML>
<HEAD>
<TITLE>Scalarsoft - ChipTrac</TITLE>
<chiptrack:checkLogon sourcePage="/engineeringReport.do?action=yieldSummary"/>
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();
    //try {
%>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href='<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css' type='text/css' rel='stylesheet'>
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<script language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>
<script>
function validatefields( fileType)
{
    var formdoc = document.engineeringReportsForm;
    errMsg = '';

    var pa = document.getElementById("errors");
    if( chkDate(formdoc.fromDate.value, 'From-Date', 'N') == false )
    {
        pa.innerHTML = errMsg;
        formdoc.fromDate.focus();
        return false;
    }
    if( chkDate(formdoc.toDate.value, 'To-Date', 'N') == false )
    {
        pa.innerHTML = errMsg;
        formdoc.toDate.focus();
        return false;
    }
    if( formdoc.fromDate.value != '' && formdoc.toDate.value != '' )
    {
        if( !validateDateOut(formatDateAsMMDDYYYY(formdoc.fromDate.value), formatDateAsMMDDYYYY(formdoc.toDate.value)) )
        {
            pa.innerHTML = "<li>To Date cannot be less than From Date</li>";
            formdoc.toDate.focus();
            return;
        }
    }
    if ( formdoc.processStep.value == '0' )
    {
        pa.innerHTML = "<li>Please select process</li>";
        formdoc.processStep.focus();
        return;
    }
    pa.innerHTML = errMsg;
    return true;
}

var dateElement = "";
function openCalendar( dateValue )
{
    dateElement = dateValue;
    newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html', 'optionsPopup', 'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
    newWindow.moveTo(550, 180);
    newWindow.focus();
}
function assignDate( passedValue )
{
    dateElement.value = passedValue;
    window.focus();
}
function selectProcessType()
{
    document.engineeringReportsForm.action = "<%=chipTracContext%>/engineeringReport.do?action=yieldSummary";
    document.engineeringReportsForm.submit();
}

function selectBaseProduct()
{
	document.engineeringReportsForm.action = "<%=chipTracContext%>/engineeringReport.do?action=yieldSummary";
    document.engineeringReportsForm.submit();
}
function submitReport(fileType)
{
    var pa = document.getElementById("errors");

    var vendorObj = document.engineeringReportsForm.vendorName;
    var vendorName = "";
    var count = 0;
    for( var i = 0; i < vendorObj.length; i++ )
    {
        if( vendorObj.options[i].selected )
        {
            count++;
            if ( vendorName != '' )
            {
                vendorName = vendorName + "," + vendorObj.options[i].value;
            }
            else
            {
                vendorName = vendorObj.options[i].value;
                if( vendorObj.options[i].value == '0' )
                {
                    break;
                }
            }
        }
    }
    if ( vendorName == '')
    {
        vendorName = "0";
    }
    if( count > 10)
    {
        pa.innerHTML = "<li>Please select upto 10 Products only";
        return false;
    }
    else
    {
        document.engineeringReportsForm.vendorName.value = vendorName;
    }

    success = true;
    success = validatefields(fileType);

    if (fileType == 1)
    {
        if( success == true ) {
            if(document.engineeringReportsForm.action.indexOf("Engineering/Test_History.rpt") != -1) {
                document.engineeringReportsForm.action = "<%=chipTracContext%>/reports/yieldReport.do?<%=Constants.REQUEST_PARAM_REPORT_NAME%>=<%=JasperReports.TEST_YIELD_REPORT%>";
            }
			else if(document.engineeringReportsForm.action.indexOf("Engineering/Sort_History_Bin.rpt") != -1) {
                document.engineeringReportsForm.action = "<%=chipTracContext%>/reports/yieldReport.do?<%=Constants.REQUEST_PARAM_REPORT_NAME%>=<%=JasperReports.SORT_YIELD_REPORT%>";
            }

            document.engineeringReportsForm.submit();
        }
    }
    else
    {
        if( success == true )
        {
            if ( fileType == 2 )
            {
                document.engineeringReportsForm.action = "<%=chipTracContext%>/engineeringReport.do?action=xlsYieldSummaryReport";
            }

            document.engineeringReportsForm.submit();
        }
    }
}
</script>
</HEAD>

<BODY bgColor='#ffffff' leftMargin='0' topMargin='0' marginheight='0'  marginwidth='0'>

<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->
<TABLE cellSpacing=0 cellPadding=0 width="100%" border="0">
    <TBODY>
        <TR>
            <td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
                <!-- Side Navigation start -->
                <%@ include file="/jsp/engineering/engg_report_menu.jsp" %>
                <!-- end of the side navigations -->
            </td>
            <TD bgcolor="#ffffff">
                <IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8>
                <!--<form name='yieldReport' method='post'>-->
                <html:form action="/engineeringReport.do?action=yieldSummary" name="engineeringReportsForm" type="com.scalar.chiptrack.engineering.forms.EngineeringReportsForm">
            </TD>
            <TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2>
            </TD>
            <TD valign="top" width="100%">
                <IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
                <BR>
                <!-- from here your body starts -->
                <center><span class="NArialW">Yield Summary Report</span></center>
                <img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10>
                <table border="0" width="90%" align="center">
                    <tr>
                        <td colspan="6" align="left" class='NArialL'>
                            <b><font align="center" color='FF0000' id="errors"></font></b>&nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td colspan="6"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td>
                    </tr>
                    <tr>
                        <td width="5%">&nbsp;</td>
                        <td width="15%" class="NArialL">Process Type</td>
                        <td width="25%" class="NArialL">
                            <html:select name="engineeringReportsForm" property="processStep" styleClass="txfield" onchange="selectProcessType()">
                                 <html:option value="0">Select Process Type</html:option>
                                <html:options collection="processList" property="value" labelProperty="label"/>
                            </html:select>
                        </td>
                        <td width="5%">&nbsp;</td>
                        <td width="15%" class="NArialL">Vendor Name </td>
                        <td width="35%" class="NArialL">
                            <html:select name="engineeringReportsForm" property="vendorName" multiple="true" size="6" styleClass="txfield">
                                <option value="0" selected>All Vendors</option>
                                <html:options collection="locationList" property="value" labelProperty="label"/>
                            </html:select>
                        </td>

                    </tr>
                    <tr>
                        <td colspan="6"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td>
                    </tr>
                    <tr>
                        <TD width="5%">&nbsp;</TD>
                        <TD width="15%" class=NArialL>Base Product Name</TD>
                        <TD width="25%" class=NArialL >
                            <html:select property="baseProductId" name="engineeringReportsForm" styleClass="txfield" onchange="selectBaseProduct()" >
                                <html:option value="0">All Base Products</html:option>
                                <html:options collection="baseProductList" property="value" labelProperty="label"/>
                            </html:select>
                        </TD>

                        <td width="5%">&nbsp;</td>
                        <td width="15%" class="NArialL">Product Name</td>
                        <td width="35%" class="NArialL">
                            <html:select name="engineeringReportsForm" property="psId" styleClass="txfield">
                                <html:option value="0">All Part Numbers</html:option>
                                <html:options collection="partNumberList" property="value" labelProperty="label"/>
                            </html:select>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="6"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td class="NArialL">From-Date</td>
                        <td class="NArialL">
                                <input type="text" name="fromDate" size="12" class="txfield">
                                <a href="javascript:openCalendar(document.engineeringReportsForm.fromDate)">
                                <img onMouseOver="window.status='Click to Select From Date';return true" onMouseOut="window.status='';return true" border="0" align='center' title="Click here to Select From Date"
                                src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=17 width=17></a>
                        </td>
                        <td>&nbsp;</td>
                        <td class="NArialL">To-Date</td>
                        <td class="NArialL">
                            <input type="text" name="toDate" size="12" class="txfield">
                            <a href="javascript:openCalendar(document.engineeringReportsForm.toDate)">
                            <img onMouseOver="window.status='Click to Select From Date';return true" onMouseOut="window.status='';return true" border="0" align='center' title="Click here to Select From Date"
                            src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=17 width=17></a>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="6"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td>
                    </tr>
                    <TR>
                        <TD width="5%">&nbsp;</TD>
                        <TD width="15%">&nbsp;</TD>
                        <TD width="25%" class="NArialL" nowrap valign = 'top' align = "left">
                        <nested:radio property="reportType" value="summary" styleClass="txfield"/>Summary &nbsp;

                        </TD>
                        <TD width="5%">&nbsp;</TD>
                        <TD width="15%" class="NArialL" nowrap valign = 'top' align = "left">
                         <nested:radio property="reportType" value="detail" styleClass="txfield"/>Detail &nbsp;</TD>
                        <TD width="35%">&nbsp;</TD>
                    </TR>
                    <tr>
                        <td colspan="6"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td>
                    </tr>
                    <tr>
                        <td colspan=5>&nbsp;</td>
                        <td colspan=1>
                            <a class="NArialL" href="javascript:submitReport(2)" onMouseOver="window.status='Click here to Export to Excel';return true" onMouseOut="window.status='';return true" title='Click here to Export to Excel' >Export to Excel</a>
                        </td>
                    </tr>

                    <tr>
                        <td colspan="6"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td>
                    </tr>

                    <tr>
                        <td colspan="6" align="center">
                            <a href="javascript: submitReport(2)"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif" width="53" height="17" onmouseover="window.status='Click to Generate Yield Report';return true" onmouseout="window.status='';return true" title="Click here to Generate Yield Report"></a>
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <a href="javascript:document.engineeringReportsForm.reset();">
                                <img src="<%=chipTracContext%>/jsp/includes/images/reset.gif" border='0' onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset">
                            </a>
                        </td>
                    </tr>
                </table>
                <BR><BR><BR>
            </TD>
            <TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1>
                </html:form>
            </TD>
        </TR>
</TABLE>
<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</BODY>
</HTML>
<%--<%}catch(Exception e){e.printStackTrace();}%>--%>
